'user strict'
import React, {Component} from 'react'

import '../../Scss/confirm'

export default class ConfirmBox extends Component {
    constructor(props) {
        super(props);
        this.state = {
            show: 0,
            sigle: 0
        };
    }
    componentWillReceiveProps() {
        setTimeout(() => {
            this.setState({show: this.props.show, sigle: this.props.sigle});
        }, 0)
    }
    render() {
        let {config, cancel, sure, cancelName, sureName} = this.props;
        let {show, sigle} = this.state;
        return (
            <div>
                {show == '1'
                    ? <div className='confirm'>
                            <div className='mask'></div>
                            <div className='cfm'>
                                <div className='title'>{config.title
                                        ? config.title
                                        : '温馨提示'}</div>
                                <div className='content'><span className="cfm_content">{config.content
                                        ? config.content
                                        : '提示内容'}</span></div>
                                {sigle == 1
                                    ? <div className='bottom'>
                                            {cancel != undefined
                                                ? <a className='item cancel' onClick={cancel.bind(this)}>{config.cancelName
                                                            ? config.cancelName
                                                            : '知道了'}</a>
                                                : ''}
                                        </div>
                                    : <div className='bottom'>
                                        {cancel != undefined
                                            ? <a className='item cancel' onClick={cancel.bind(this)}>{config.cancelName
                                                        ? config.cancelName
                                                        : '取消'}</a>
                                            : ''}
                                        {sure != undefined
                                            ? <a className='item sure' onClick={sure.bind(this)}>{config.sureName
                                                        ? config.sureName
                                                        : '确定'}</a>
                                            : ''}
                                    </div>}
                            </div>
                        </div>
                    : ''
}
            </div>

        )
    }
}
